'use strict';

module.exports = {
  // 获取token
  getToken(options) {
    return this.app.jwt.sign(options, this.app.config.jwt.secret, { expiresIn: '1800s' });
  },

  // 失败响应
  res_fail(data, message = 'fail', status = 200, code = 0) {
    this.ctx.status = status;
    this.ctx.body = {
      code,
      data,
      message,
    };
  },

  // 成功响应
  res_success(data, message = 'success') {
    this.ctx.status = 200;
    this.ctx.body = {
      code: 1,
      message,
      data,
    };
  },

};
